package com.atstudy.headline.web.app.mapper;

import com.atstudy.headline.entity.UserFollows;
import com.atstudy.headline.entity.Users;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.apache.ibatis.annotations.Select;

/**
* @author A
* @description 针对表【user_follows(用户关注关系表)】的数据库操作Mapper
* @createDate 2025-06-12 13:55:01
* @Entity com.atstudy.headline.entity.UserFollows
*/
public interface UserFollowsMapper extends BaseMapper<UserFollows> {

    /**
     * 关注列表
     * @param page
     * @param userId
     * @return
     */
    @Select("SELECT  u.username,u.bio,u.user_id,u.avatar_url FROM  user_follows uf JOIN users u ON uf.followee_id = u.user_id WHERE uf.follower_id = #{userId}" +
            " AND uf.status = 1")
    IPage<Users> getFollowing(IPage<Users> page, Integer userId);

    /**
     * 粉丝列表
     * @param page
     * @param userId
     * @return
     */
    @Select("SELECT u.username,u.bio,u.user_id,u.avatar_url FROM user_follows uf JOIN  users u ON uf.follower_id = u.user_id" +
            " WHERE uf.followee_id = #{userId} AND uf.status = 1")
    IPage<Users> getFollower(IPage<Users> page, Integer userId);
}




